package com.itheima.Config;

import com.itheima.interceptor.DemoInterceptor2;
import com.itheima.interceptor.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class webConifg implements WebMvcConfigurer {
//自定义的拦截器对象
    @Autowired
    private DemoInterceptor2 demoInterceptor2;
    @Autowired
    private TokenInterceptor tokenInterceptor;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册自定义拦截器对象
//        设置拦截器拦截的请求路径
        registry.addInterceptor(demoInterceptor2).addPathPatterns("/**");
        registry.addInterceptor(tokenInterceptor)
                //拦截路径
                .addPathPatterns("/**")
                //放行路径
                .excludePathPatterns("/login");

    }
}
